import Taro from '@tarojs/taro';
import React, { useEffect, useState } from 'react';
import { View, Image, Button } from '@tarojs/components';
import { AtForm, AtInput, AtImagePicker, AtDivider } from 'taro-ui';
import Information from '../../../components/Information/Information';
import { Current } from '@tarojs/runtime';
import NavBar from '../fit';
import './auditing.scss';
const Auditing = () => {

  //用来保存来自message页面中的数据
  const [list1, setList1] = useState([{}])
  console.log("list:", JSON.parse(decodeURIComponent(Current.router.params.list)))
  // 获取路由传参，并事实数据传递(同步)
  useEffect(() => {
    let data = JSON.parse(decodeURIComponent(Current.router.params.list))
    setList1([data])
  }, [])
  console.log("newlist:", list1)


  // const handleClick = () => {
  //   Taro.navigateTo({
  //     url: '/pages/my/auditing/message',
  //   });
  // };

  const Multi_select = item => {
    if (item !== null) {
      Taro.previewImage({
        current: item[0],//我猜得是你们多半是列表得形式保存，[]是用来获取第几个得，我这设置得是列表中得第一张
        urls: item//这个只是用来替代item.file.path得参数，你可以理解成  item===item.file.path
      })
    }
    return 0
  }

  //导出详细数据
  const List = list1.map((content) => (
    <View className="box1">
      <View className="box11">
        <View className="inf">营养师审核信息</View>
        <View className="nt">
          <View className="name">
            <View>{content.enroll_name}</View>
            <AtDivider height="60" />
          </View>
          <View className="tel">
            <View>{content.enroll_phone}</View>
            <AtDivider height="60" />
          </View>
        </View>
        <View className="iden">{content.enroll_idCard}</View>
        <AtDivider height="60" />
        <View className="pic">照片</View>
        {/* 照片数据*/}
        <View className="picpic" >
          <Image className="imgSrc" onClick={()=>{Multi_select([content.qualification])}} src={content.qualification} />
        </View>
      </View>
    </View>

  ))
  const toBack=()=>{
    Taro.navigateBack().then();
  }
  const toHome=()=>{
    Taro.redirectTo({url:"/pages/firstPage/firstPage"}).then();
  }

  return (
    <View className="box">
      <NavBar
        title="审核信息"
        // color="#ffffff"
        back={true}
        nback={toBack}
        home={true}
        onHome={toHome}

      />


      <AtForm className="bd">
        {List}

        <Information openid={list1[0].openid} />
        {/* <View className="box2">
          <Button className="box21" formType='submit' onClick={Submit}>通过</Button>
          <Button className="box22" formType='reset' onClick={reset}>退回</Button>
        </View> */}
      </AtForm>
    </View>
  )
}
export default Auditing
